<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bootstrap_Supermarket</title>
    <link rel="stylesheet" href="../libs/jquery-3.4.1.min.js">
    <link rel="stylesheet" href="../libs/bootstrap_libs/css/bootstrap.min.css">
    <link rel="stylesheet" href="../libs/bootstrap_libs/fonts/glyphicons-halflings-regular.eot">
    <link rel="stylesheet" href="../css/index.css">
    <script src="../js/utils.js"></script>
    <script src="../libs/jquery-3.4.1.min.js"></script>
    <script src="../libs/bootstrap_libs/js/bootstrap.js"></script>
    <style>
        *{padding: 0;margin: 0;}
        img{
            width: 30px;
            height: 30px;
            transition: transform 1s;
            cursor: pointer;
        }
        img:hover{
            transform: scale(7,4);
            transition: 1s;
        }
        .ct{
            text-align: center;
        }
        .auto1{
            margin-left: 450px;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-default">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Bootstrap_Supermarket</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="../index.html">首页</a></li>
                    <li class="active"><a href="#">海鲜区</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">登录</a></li>
                    <li><a href="#">注册</a></li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
    <div class="container">
        <button class="btn btn-primary" onclick="getGirls()">
            更多
        </button>
        <table class="table table-shop table-striped table-bordered table-hover table-condensed">
            <thead>
                <tr class="ct">
                    <th class="ct">编号</th>
                    <th class="ct">照片</th>
                    <th class="ct">描述</th>
                    <th class="ct">操作</th>
                </tr>
            </thead>
            <tbody>

            </tbody>

        </table>
        <nav aria-label="Page navigation">
            <ul class="pagination auto1">
                <li>
                    <a href="#" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                <li><a class="page-btn" href="#">1</a></li>
                <li><a class="page-btn" href="#">2</a></li>
                <li><a class="page-btn" href="#">3</a></li>
                <li><a class="page-btn" href="#">4</a></li>
                <li><a class="page-btn" href="#">5</a></li>
                <li>
                    <a href="#" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
    <script>
        const tb = document.querySelector('.table')
        const url = "http://api.tianapi.com/meinv/index"
        var query = { key: "35705ec28dbe6f3b4f34640d39651750", num: 10, rand: 1 }
        getGirls()
        function getGirls(page){
            utils.fetch(url,query).then(resp=>{
                query.page = page
                var list = resp.newslist
                list.forEach((item,index)=>{
                    var str=`
                    <td class="ct">${index+1}</td>
                    <td style="text-align:center">
                        <img src="${item.picUrl}" alt="${item.title}" title="${item.description}">
                    </td>
                    <td class="ct">
                        ${item.title}${item.ctime}
                    </td>
                    <td class="ct">
                        <a href="${item.url}">
                            <button class="btn-xs btn btn-info ct">详情</button>
                        </a>
                    </td>
                    `
                    var tr = document.createElement('tr')
                    tr.innerHTML = str
                    tb.querySelector('tbody').appendChild(tr)
                })
            })
        }

        document.addEventListener("click",e=>{
            if(e.target.className == "page-btn"){
                tb.querySelector('tbody').innerHTML=""
                getGirls(e.target.innerHTML)
            }
        })
    </script>
</body>
</html>